package gui;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.text.DecimalFormat;

import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ControlFrame extends JApplet
{
	private JRetina gGraph = null;
	
	private JLabel inputStatusLabel = new JLabel("INPUT IS OFF");
	private JLabel noiseLabel = new JLabel("Noise μ: ");
	
	private JPanel controlPane = new JPanel();
	
	private static boolean inputOn = false;
	
	public ControlFrame()
	{
		this.gGraph = new JRetina();
	}
	
	public void init()
	{
		Container cp = getContentPane();
		cp.add(gGraph);
		
		//JLabel Setup
		inputStatusLabel.setForeground(Color.RED);
		
		//JPanel Control Setup
		controlPane.setOpaque(true);
		controlPane.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		
		c.fill = GridBagConstraints.VERTICAL;
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 0;
		c.gridy = 0;
		controlPane.add(inputStatusLabel, c);
		
		c.fill = GridBagConstraints.VERTICAL;
		c.weightx = 0;
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 0;
		c.gridy = 2;
		controlPane.add(noiseLabel, c);
		
		cp.add("West", controlPane);
		
	}
	
	public void force_repaint()
	{
		this.validate(); this.repaint();
		gGraph.validate(); gGraph.repaint();
	}
	
	public static double roundTwoDecimals(double d) 
	{
        DecimalFormat twoDForm = new DecimalFormat("#.##");
        return Double.valueOf(twoDForm.format(d));
	}
	
	//PRIVATE CLASS
	private class JRetina extends JPanel
	{
		
		public JRetina()
		{		
			
		}
		
		@Override
		public void paintComponent(final Graphics g)
		{
			//g.drawString("Hello World", 20, 30);
			
			g.setColor(Color.RED);
			g.drawRect(0, 0, 726, 570);
			
			paintGrid(g);
		}
		
		private void paintGrid(final Graphics g)
		{
			
		}
	}
}
